package com.xiaohai.wx.weather.util;

import java.util.Calendar;
import java.util.Date;

import org.joda.time.DateTime;


public class DateUtil {
	
	public static boolean isToday(Date date){
		Calendar today = Calendar.getInstance();
		Calendar target = Calendar.getInstance();
		target.setTime(date);
		if(today.get(Calendar.YEAR) == target.get(Calendar.YEAR) 
				&& today.get(Calendar.DAY_OF_YEAR) == target.get(Calendar.DAY_OF_YEAR)){
			return true;
		}else{
			return false;
		}
	}
	
	public static boolean is3DaysOld(Date lastUpdatedTime) {
		Date now = new Date();

		long diff = now.getTime() - lastUpdatedTime.getTime();
		long diffDays = diff / (24 * 60 * 60 * 1000);
		if (diffDays > 3) {
			return true;
		} else {
			return false;
		}
	}
	
	public static boolean nowIsMorning(){
		
		DateTime targetTime = new DateTime(); 
		int hour = targetTime.getHourOfDay();
		if( hour>=0 && hour <12){
			return true;
		}else{
			return false;
		}
	}
	

}
